package com.ruoyi.training.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.training.service.ICertificateReissueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.training.domain.CertificateReissue;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 换证管理Controller
 * 
 * @author hcc
 * @date 2025-11-06
 */
@RestController
@RequestMapping("/certificateReissue")
public class CertificateReissueController extends BaseController
{
    @Autowired
    private ICertificateReissueService certificateReissueService;

    /**
     * 查询换证管理列表
     */
    @RequiresPermissions("training:certificateReissue:list")
    @GetMapping("/list")
    public TableDataInfo list(CertificateReissue certificateReissue)
    {
        startPage();
        List<CertificateReissue> list = certificateReissueService.selectCertificateReissueList(certificateReissue);
        return getDataTable(list);
    }

    /**
     * 导出换证管理列表
     */
    @RequiresPermissions("training:certificateReissue:export")
    @Log(title = "换证管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CertificateReissue certificateReissue)
    {
        List<CertificateReissue> list = certificateReissueService.selectCertificateReissueList(certificateReissue);
        ExcelUtil<CertificateReissue> util = new ExcelUtil<CertificateReissue>(CertificateReissue.class);
        util.exportExcel(response, list, "换证管理数据");
    }

    /**
     * 获取换证管理详细信息
     */
    @RequiresPermissions("training:certificateReissue:query")
    @GetMapping(value = "/{certificateReissueId}")
    public AjaxResult getInfo(@PathVariable("certificateReissueId") String certificateReissueId)
    {
        return success(certificateReissueService.selectCertificateReissueByCertificateReissueId(certificateReissueId));
    }

    /**
     * 新增换证管理
     */
    @RequiresPermissions("training:certificateReissue:add")
    @Log(title = "换证管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CertificateReissue certificateReissue)
    {
        return toAjax(certificateReissueService.insertCertificateReissue(certificateReissue));
    }

    /**
     * 修改换证管理
     */
    @RequiresPermissions("training:certificateReissue:edit")
    @Log(title = "换证管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CertificateReissue certificateReissue)
    {
        return toAjax(certificateReissueService.updateCertificateReissue(certificateReissue));
    }

    /**
     * 删除换证管理
     */
    @RequiresPermissions("training:certificateReissue:remove")
    @Log(title = "换证管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{certificateReissueIds}")
    public AjaxResult remove(@PathVariable String[] certificateReissueIds)
    {
        return toAjax(certificateReissueService.deleteCertificateReissueByCertificateReissueIds(certificateReissueIds));
    }
}
